package problems;

import java.util.Calendar;

public class Euler019 extends AbstractEuler {

	@Override
	public Number calculate() {
		Calendar c = Calendar.getInstance();
		c.set(1901, Calendar.JANUARY, 1, 12, 0, 0);
		
		Calendar finish = Calendar.getInstance();
		finish.set(2000, Calendar.DECEMBER, 31, 12, 0, 0);
		
		Long sundaysOnTheFirst = 0L;
		
		while (c.before(finish)) {
			if (c.get(Calendar.DAY_OF_MONTH) == 1 && c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) sundaysOnTheFirst++;
			c.add(Calendar.MONTH, 1);
		}
		
		return sundaysOnTheFirst;
	}

	@Override
	protected Number getCorrectAnswer() {
		return 171L;
	}

}
